"""
物种，病害Model
最后修改：3.29
修改人：陈泯全
"""
from sqlalchemy import Column, Integer, String,ForeignKey
from sqlalchemy.orm import relationship,backref
from utils.dataBase import Base

class Speices(Base):
    __tablename__ = "speices"
    sid = Column(Integer, primary_key=True)
    sname = Column(String(50), unique=True, nullable=False)
    sinfo = Column(String(50), unique=True, nullable=False)
    ssug = Column(String(50), unique=True, nullable=False)

    def __init__(self, sname, sinfo, ssug):
        self.sname = sname
        self.sinfo = sinfo
        self.ssug = ssug

    def __repr__(self):
        return '<Speices %r>' % self.sname

class Disease(Base):
    __tablename__ = "disease"
    did = Column(Integer, primary_key=True)
    dname = Column(String(50), unique=True, nullable=False)
    dinfo = Column(String(50), unique=True, nullable=False)
    dheal = Column(String(50), unique=True, nullable=False)
    dprevent = Column(String(50), unique=True, nullable=False)
    sid = Column(String(50), ForeignKey('speices.sid'))

    speices = relationship('Speices', backref=backref('diseases', lazy=True))

    def __init__(self,dname, dinfo, dheal, dprevent, sid):
        self.dname = dname
        self.dinfo = dinfo
        self.dprevent = dprevent
        self.sid = sid

    def __repr__(self):
        return '<Disease %r>' % self.dname

